from utils.common import return_ins

def get_lm_from_json(lm_json):
    if lm_json['weights_file']=='':
        if lm_json['filetype']=='source':
            modulename=lm_json['modulename']
            classname=lm_json['classname']
            parameters=lm_json['parameters']
            attribute=lm_json['attribute']
            model=return_ins(modulename,classname,parameters,attribute)
    
    return model

def get_lm(lm):
    if lm.filetype==0:
            modulename=lm.modulename
            classname=lm.classname
            parameters=lm.parameters
            attribute=lm.attribute
            model=return_ins(modulename,classname,parameters,attribute)
    
    return model